package com.lpit.controller;

import com.lpit.dto.BarChartDto;
import com.lpit.service.impl.ArticleServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * @author yaochen
 * @version 1.0.1
 */
@Controller
@RequestMapping("/content-statistics")
public class ContentStatisticsController {

    @Autowired
    ArticleServiceImpl articleService;
    /**
     * @author yaochen
     * @apiNote 文章的总量
     * @return Integer
     */
    @RequestMapping("/articlesNumber")
    @ResponseBody
    public Integer  articlesNumber(){
        return articleService.articlesNumber();
    }
    /**
     * @author yaochen
     * @apiNote 评论数
     * @return Integer
     */
    @RequestMapping("/commentsNumber")
    @ResponseBody
    private Integer commentsNumber(){
        return articleService.commentsNumber();
    }
    /**
     * @author yaochen
     * @apiNote 阅读量
     * @return Integer
     */
    @RequestMapping("/readingQuantity")
    @ResponseBody
    public Integer readingQuantity(){
        return articleService.readingQuantity();
    }
    /**
     * @author yaochen
     * @apiNote 转发数
     * @return Integer
     */
    @RequestMapping("/forwardingNumber")
    @ResponseBody
    public Integer forwardingNumber(){
        return articleService.forwardingNumber();
    }
    /**
     * @author yaochen
     * @apiNote 柱状图，按文章的发布时间段查询文章数。
     * @return Integer
     */
    @RequestMapping("/articlesNumberTime/{startDate}/{endDate}")
    @ResponseBody
    public List<BarChartDto> articlesNumberTime(@PathVariable String startDate,@PathVariable String endDate){
        return articleService.articlesNumberTime(startDate,endDate);
    }
    /**
     * @author yaochen
     * @apiNote 柱状图，按文章的发布时间段查询文章数。
     * @return Integer
     */
    @RequestMapping("/readingQuantityTime/{startDate}/{endDate}")
    @ResponseBody
    public List<BarChartDto> readingQuantity(@PathVariable String startDate,@PathVariable String endDate){
        return articleService.selectReadingQuantity(startDate,endDate);
    }
    /**
     * @author yaochen
     * @apiNote 柱状图，按文章的发布时间段查询文章数。
     * @return Integer
     */
    @RequestMapping("/commentsNumberTime/{startDate}/{endDate}")
    @ResponseBody
    public List<BarChartDto> commentsNumber(@PathVariable String startDate,@PathVariable String endDate){
        return articleService.selectCommentsNumber(startDate,endDate);
    }

}